package com.dizner.diassistant.datadao

import androidx.room.*
import com.dizner.diassistant.dataentry.BloodPressureHistoryEntry
import io.reactivex.Maybe
import io.reactivex.Single

@Dao
interface BloodPressureHistoryDao {

    @Query("SELECT * FROM blood_pressure_history ORDER BY createTime")
    fun getAllHistory(): Single<List<BloodPressureHistoryEntry>>


    @Query("SELECT* FROM blood_pressure_history WHERE createTime LIKE :date || '%'  ORDER BY createTime")
    fun getHistoryByDate(date: String): Single<List<BloodPressureHistoryEntry>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun addNewHistory(entry: BloodPressureHistoryEntry): Single<Long>

    @Delete
    fun deleteHistory(entry: BloodPressureHistoryEntry): Single<Int>

    @Delete
    fun clearHistory(entryList: List<BloodPressureHistoryEntry>): Single<Int>
}